package com.rui.strategy.model;

import com.rui.strategy.obj.pay.AliPayment;
import com.rui.strategy.obj.pay.CashPayment;
import com.rui.strategy.obj.pay.Payment;
import com.rui.strategy.obj.pay.WeChatPayment;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Description: 支付方式容器策略类
 * @Author: ZhangRui
 * @Date: 2023/3/3 13:45
 * @Version: 1.0
 */
public class PaymentStrategy {

    private static Map<String, Payment> map = new ConcurrentHashMap<>();

    static {
        map.put("WeChat", new WeChatPayment());
        map.put("Ali", new AliPayment());
    }

    public static Payment getPayment(String payment) {
        return map.get(payment) == null ? new CashPayment() : map.get(payment);
    }

}
